- TKey
- TValue
Library/Library.Test/TestOrderedEnumeration.cs
C# | Copy Code |
---|---|
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>(); Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer)); Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer)); Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1))); Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2))); Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1))); |
VB.NET | Copy Code |
---|---|
Dim cmp As New KeyValueComparer(Of Integer, Integer)() Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer)) Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer)) Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1))) Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2))) Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1))) |
System.Object
CSharpTest.Net.Collections.KeyValueComparer<TKey,TValue>
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7